#include <iostream>
#include <vector>

using namespace std;
class Solution
{
public:
    int numWaterBottles(int numBottles, int numExchange)
    {
        int ans = numBottles;
        while (numBottles >= numExchange)
        {
            ans += numBottles / numExchange;
            numBottles = numBottles / numExchange + numBottles % numExchange;
        }
        return ans;
    }
};
int main()
{
    Solution s;
    int numBottles = 15, numExchange = 4;
    cout << s.numWaterBottles(numBottles, numExchange) << endl;
    return 0;
}